<?php

namespace app\index\controller;

use hehe\AliyunSms;
use ba\Tree;
use hehe\Network;
use think\facade\View;
use Throwable;
use think\facade\Db;
use think\facade\Cookie;
use think\facade\Config;
use app\common\controller\Frontend;

class Test extends Frontend {
    protected array $noNeedLogin = ['*'];

    public function initialize(): void {
        parent::initialize();
    }

    public function index(){

        $accessKeyId = 'LTAI5tDiAB9KnbqoPQskZNw5';
        $accessKeySecret = 'fKqzptVU4XQevsuen7BklcM4Is2jBn';

        $signName = '微微软件';
        $templateCode = 'SMS_468675307';


        $sms = new AliyunSms($accessKeyId, $accessKeySecret, $signName, $templateCode);
        $phoneNumbers = '手机号'; // 需要发送短信的手机号
        $templateParam = [
            'code' => '123456' // 模板中变量的值
        ];
        $result = $sms->sendSMS($phoneNumbers, $templateParam);

        if ($result) {
            echo '短信发送成功';
        } else {
            echo '短信发送失败';
        }
    }
}